//
//  MTShareFriendViewController.m
//  ShiShiBang
//
//  Created by 宋宝强 on 16/9/23.
//  Copyright © 2016年 motianjituan. All rights reserved.
//

#import "MTShareFriendViewController.h"
#import "UMSocial.h"
@interface MTShareFriendViewController ()<UMSocialUIDelegate>

@end

@implementation MTShareFriendViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.backgroundColor = [UIColor redColor];
    btn.frame = CGRectMake(50, 50, 50, 50   );

    [btn setTitle:@"分享" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(sendmsg) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    [self initNavigation];
    self.view.backgroundColor = UIColorFromRGB(0xf7f7f7);
}

-(void)initNavigation {
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"back"] highImage:[UIImage imageNamed:@"back anxia"] target:self action:@selector(backClick)];
    self.navigationItem.title = @"邀请好友";
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:UIColorFromRGB(0x45c75a)]  forBarMetrics:UIBarMetricsDefault];
    NSMutableDictionary *attr = [NSMutableDictionary dictionary];
    attr[NSFontAttributeName] = [UIFont boldSystemFontOfSize:17];
    attr[NSForegroundColorAttributeName] = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:attr];
}

-(void)backClick {
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)sendmsg {
    
    [[UMSocialData defaultData].urlResource setResourceType:UMSocialUrlResourceTypeImage url:@"http://baike.baidu.com/pic/%E5%9B%BE%E7%89%87/372416/0/29381f30e924b899c83ff41c6d061d950a7bf697?fr=lemma&ct=single#aid=958897&pic=d62a6059252dd42a8acc842f033b5bb5c8eab869"];
    [UMSocialData defaultData].extConfig.title = @"英雄联盟";
    [UMSocialData defaultData].extConfig.wechatTimelineData.title = @"微信朋友圈title";
    [UMSocialData defaultData].extConfig.wechatSessionData.title = @"微信好友title";
    //    设置点击分享内容跳转链接
    [UMSocialData defaultData].extConfig.qqData.url = @"http://mall.c2mall.cc/";
    [UMSocialData defaultData].extConfig.wechatSessionData.url = @"http://mall.c2mall.cc/";
    [UMSocialData defaultData].extConfig.wechatTimelineData.url = @"http://mall.c2mall.cc/";
    //    设置分享消息类型  微信的
    //    纯图片分享类型方法为
    [UMSocialData defaultData].extConfig.wxMessageType = UMSocialWXMessageTypeImage;
    //    纯文字分享类型方法为
    [UMSocialData defaultData].extConfig.wxMessageType = UMSocialWXMessageTypeText;
    //    应用分享类型方法
    [UMSocialData defaultData].extConfig.wxMessageType = UMSocialWXMessageTypeApp;
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"57d377db67e58ebdab002059"
                                      shareText:@"梦想还是要有的"
                                     shareImage:[UIImage imageNamed:@"icon"]
                                shareToSnsNames:@[UMShareToWechatSession,UMShareToWechatTimeline,UMShareToSina,UMShareToQQ,UMShareToQzone]
                                       delegate:self];
}


-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
{
    //根据`responseCode`得到发送结果,如果分享成功
    if(response.responseCode == UMSResponseCodeSuccess)
    {
        //得到分享到的平台名
        NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
    }
}


@end
